package com.mojian.controller.article;

import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.mojian.entity.SysZb;
import com.mojian.service.SysZbService;
import com.mojian.common.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;

/**
 * 招标 控制器
 */
@RestController
@RequestMapping("/sys/sysZb")
@RequiredArgsConstructor
@Api(tags = "招标管理")
public class SysZbController {

    private final SysZbService sysZbService;

    @GetMapping("/list")
    @ApiOperation(value = "获取招标列表")
    public Result<IPage<SysZb>> list(SysZb sysZb) {
        return Result.success(sysZbService.selectPage(sysZb));
    }

    @GetMapping("/listZbz")
    @ApiOperation(value = "获取招标中列表")
    public Result<List<Map<String, Object>>> listZbz() {
        return Result.success(sysZbService.selectZBZList());
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取招标详情")
    public Result<SysZb> getInfo(@PathVariable("id") Long id) {
        return Result.success(sysZbService.getById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加招标")
    public Result<Object> add(@RequestBody SysZb sysZb) {
        return Result.success(sysZbService.insert(sysZb));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改招标")
    public Result<Object> edit(@RequestBody SysZb sysZb) {
        return Result.success(sysZbService.update(sysZb));
    }

    @PutMapping("/updateJh")
    @ApiOperation(value = "激活招标")
    public Result<Object> editJh(@RequestBody SysZb sysZb) {
        return Result.success(sysZbService.updateJh(sysZb));
    }

    @PutMapping("/updateQxJh")
    @ApiOperation(value = "取消激活招标")
    public Result<Object> updateQxJh(@RequestBody SysZb sysZb) {
        return Result.success(sysZbService.updateQxJh(sysZb));
    }

    @DeleteMapping("/delete/{ids}")
    @ApiOperation(value = "删除招标")
    public Result<Object> remove(@PathVariable List<Long> ids) {
        return Result.success(sysZbService.deleteByIds(ids));
    }
}
